package com.ghh.mapper;


import com.ghh.domain.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.ExampleMapper;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.special.InsertListMapper;

import java.util.List;

@Repository
public interface UserMapper extends Mapper<User>, InsertListMapper<User>, ExampleMapper<User> {

    //查
    @Select("select * from user")
    List<User> findAll();

    //增
    @Insert("insert into user (username,password) values (#{username},#{password})")
    Integer addUser(User user);

    //改
    @Update("update  user set username=#{username},password=#{password} where id=#{id}")
    Integer edit(User user);

    //删
    @Delete("delete from user where id=#{id}")
    Integer deleteById(Integer id);
}
